EbN0_db_set = 0:6;
totalBitNum = 1D+5;
global errBitNum;

load(SCICOM+"\demos\baseband\basebandSystemBERSimulation.cos");

for i = 1:length(EbN0_db_set)
  EbN0_db = EbN0_db_set(i);
  Tb = 1;
  
  %scicos_context.EbN0_db = EbN0_db;
  disp(strcat(["simulating Eb/N0: ", string(EbN0_db),' dB']))

  tf = totalBitNum + 11;
  scs_m.props.tf = tf;
  scicos_simulate(scs_m, list(), %scicos_context);
  BER(i) = errBitNum/totalBitNum;
end

plot(EbN0_db_set, log10(BER), "*")

//theoretical BER
EbN0_db = 0:0.1:10;
EbN0 = 10^(EbN0_db/10);
theoryBER = 0.5*erfc(sqrt(EbN0)); 
plot(EbN0_db, log10(theoryBER))
xtitle('BER performance of baseband system','Eb/N0 (db)','Log10(BER)')


